package com.ak.demo.config;

import com.ak.demo.dao.UserMapper;
import com.ak.demo.entity.User;
import com.ak.demo.service.impl.LoginServiceImpl;
import com.ak.demo.utils.ResponseUtils;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.quartz.PersistJobDataAfterExecution;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

/**
 * 每天 0点 开始刷新 健康打卡系统
 */
@PersistJobDataAfterExecution
public class LoginJob implements Job {


    @Autowired
    UserMapper userMapper;

    @Autowired
    LoginServiceImpl service;

    @Override
    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        List<User> users=userMapper.selectList(null);
        //
        for(User user:users){
            String body= ResponseUtils.connect(user.getUsername(),user.getPassword());
            service.email(body,user.getEmail());
        }
    }
}
